package com.jichaoyun.controller;

import com.jichaoyun.common.model.PagedResult;
import com.jichaoyun.common.model.Result;
import com.jichaoyun.model.vo.InspectVo;
import com.jichaoyun.service.StationInspectionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

@RestController
@Api(tags = {"巡检接口"})
@RequestMapping("/sys/inspection")
public class StationInspectionController {

    @Autowired
    private StationInspectionService stationInspectionService;



//    //待删除
//    @ApiOperation("巡检管理，查看巡检记录")
//    @GetMapping("/getInspectionInfo")
//    public Result<PagedResult> getInspectionInfo(String date, Integer pageNo) {//@RequestBody是做json字符串的转换
//        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
//        LocalDate datetime = LocalDate.parse(date,dateTimeFormatter);
//        return Result.success(stationInspectionService.getStationInspectionInfo(datetime,pageNo,20));
//    }
//
//    //待改造
//    @ApiOperation(value = "巡检管理，今日巡检信息导出到excel")
//    @GetMapping("/DownloadTodayStationInspection")
//    public void DownloadTodayStationInspection(String date,HttpServletResponse response) throws IOException {
//
//        stationInspectionService.getStationInspectionExcel(date,response);
//    }
//
//
//    //待删除
//    @ApiOperation(value = "巡检管理，历史巡检信息导出到excel")
//    @GetMapping("/DownloadStationInspection")
//    public void DownloadValveAlarmInfoPage(HttpServletResponse response) throws IOException {
//
//        stationInspectionService.getStationInspectionExcel(response);
//    }

    @ApiOperation("巡检管理，查询巡检记录")
    @GetMapping("/getInspectInfo")
    public Result<?> getInspectInfo(String date,String type){
        return Result.success(stationInspectionService.getInspectInfo(date,type));
    }

    @ApiOperation("巡检管理，插入巡检记录")
    @PostMapping("/insertInspectInfo")
//    @MustLog(title = "巡检管理模块",content = "插入巡检记录")
    public Result<?> insertInspectInfo(@RequestBody InspectVo inspectVo){
        return Result.success(stationInspectionService.insertInspectInfo(inspectVo));
    }

    @ApiOperation("巡检管理，插入巡检签名图片")
    @PostMapping("/insertSignatureInspectPhoto")
//    @MustLog(title = "巡检管理模块",content = "插入巡检记录")
    public Result<?> insertSignatureInspectPhoto(Integer num, MultipartFile signature){
        return Result.success(stationInspectionService.insertSignatureInspectPhoto(num,signature));
    }

    @ApiOperation("巡检管理，插入巡检图片")
    @PostMapping("/insertInspectPhoto")
//    @MustLog(title = "巡检管理模块",content = "插入巡检图片")
    public Result<?> insertInspectPhoto(Integer num,MultipartFile photo){
        return Result.success(stationInspectionService.insertInspectPhoto(num,photo));
    }




}
